home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14135 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  53 lines

  1. Path: mail2news.demon.co.uk!setch.demon.co.uk
  2. From: Mark Setchell <Mark@setch.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: #including everything
  5. Date: Fri, 12 Apr 96 08:24:41 GMT
  6. Organization: DeltaPlusLtd
  7. Message-ID: <829297481snz@setch.demon.co.uk>
  8. Reply-To: Mark@setch.demon.co.uk
  9. X-NNTP-Posting-Host: setch.demon.co.uk
  10. X-Newsreader: Demon Internet Simple News v1.27
  11. X-Mail2News-Path: setch.demon.co.uk
  12.  
  13. Does anyone have an opinion about how sensible it is to #include all
  14. standard system header files in C programs? I work on a project with
  15. approximately 2000 files and 500,000 lines of code and every file
  16. has a long piece at the start like this:
  17.  
  18. #include <stdio.h>
  19. #include <errno.h>
  20. #if !defined(SGI) && !defined(HPUX)
  21. #include <x.h>
  22. #else
  23. #if !defined(IBM_R2) && !defined(CRAY)
  24. #include <y.h>
  25. #endif
  26. #endif
  27.  
  28. This is obviously a maintenance nightmare, porting is no fun either. I
  29. am thinking of making a single include file with all system headers in
  30. it (i.e. ones in <> as opposed to those in "").
  31.  
  32. I suspect the disadvantages are:
  33. 1) If it changes, all files have to be rebuilt - but that's ok it won't
  34.    change often
  35. 2) It may bloat the size of the binaries by including unused variables,
  36.    but that's not really a problem on Virtual Memory machines, and the
  37.    increase in size isn't much anyway.
  38. 3) ???
  39.  
  40. Weighed against this, the advantages are:
  41. 1) porting and maintenance become easier with only one file to maintain
  42. 2) all system calls/functions are guaranteed to be prototyped
  43. 3) ???
  44.  
  45. Also, which system files should I #include?
  46.  
  47. TIA
  48. -- 
  49. Mark Setchell (Mark@setch.demon.co.uk)
  50. 17 Hurst Place, Gillingham, Kent, England ME8 9AS
  51. Tel: +44-1634-264198
  52. Fax: +44-1634-264199
  53.